package com.kuang.service;

import com.kuang.pojo.Candidate;
import com.kuang.pojo.Exam;
import com.kuang.pojo.Rank;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class ExamServiceImpl implements  ExamService {

    //service 调用 dao
    @Autowired
    private com.kuang.dao.ExamMapper ExamMapper;

    public void setExamMapper(com.kuang.dao.ExamMapper examMapper) {
        ExamMapper = examMapper;
    }

//    public void addPass(String days,String times,String place,int cid) {
//        HashMap<String,Object> map = new HashMap<String,Object>();
//        System.out.println("表单传过来的值"+  days+times+place+cid);
//        map.put("v_days", days);
//        map.put("v_times", times);
//        map.put("v_places",place);
//        map.put("v_userid",cid+"");
//        ExamMapper.addPass(map);
//    }
    public void addPass(String days, String times, String place,String code, Candidate Candidate){
        String passnum=code+Candidate.getIDNUM();
        System.out.println("passnum=>"+passnum);
        int cid=Candidate.getCID();
        String passpwd=code;
        ExamMapper.addPass(days, times,place, cid,passnum, passpwd);
    }

    public void updateExam(String status, int eid, int grade) {
        ExamMapper.updateExam(status,eid,grade);
    }

    public List<Exam> allExam(int cid) {
        return ExamMapper.allExam(cid);
    }


    public Exam getExamByid(int cid,String code) {
        return ExamMapper.getExamByid(cid,code);
    }

    public Exam Login(String passnum,String passpwd,int cid){
        return ExamMapper.Login(passnum,passpwd,cid);
    }

    public List<Rank> getRank() {
        return ExamMapper.getRank();
    }
}
